<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'user.label', default: 'User')}"/>
    <title>修改企业固定资产</title>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>贷款管理系统</li>
                    <li class="active">
                        <span>修改企业固定资产</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                修改企业固定资产
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:if test="${flash.message}">
            <div class="message" role="status">${flash.message}</div>
        </g:if>
        <g:hasErrors bean="${this.propertyInformation}">
            <ul class="text-danger" role="alert">
                <g:eachError bean="${this.propertyInformation}" var="error">
                    <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                        <g:message error="${error}"/>
                    </li>
                </g:eachError>
            </ul>
        </g:hasErrors>
        <div class="hpanel hblue">
            <div class="panel-heading">
                修改企业固定资产
            </div>

            <div class="panel-body">
                <g:form resource="${this.propertyInformation}" method="PUT" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-md-2 control-label">公司名称</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="account" value="${this.propertyInformation?.account?.id}"
                                      optionKey="id" optionValue="name" from="${com.next.Account.list()}" disabled="true"/>
                        </div>
                        <label class="col-md-2 control-label">权利证书号</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="certificate.serialNumber" id="certificate" value="${propertyInformation?.certificate?.serialNumber}" onchange="getCertificateNumber()"/>
                            <input class="form-control" name="certificate.id" type="hidden" id="certificateId"
                                   value="${propertyInformation?.certificate?.id}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">币种</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="currencyType" value="${propertyInformation?.currencyType?.id}"
                                      optionKey="id" optionValue="name" from="${com.next.CurrencyType.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">评估日期</label>

                        <div class="col-md-3 datePicker">
                            <g:datePicker name="valuationDate"  value="${propertyInformation?.valuationDate}" precision="day"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">评估机构</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="valuationProvider" value="${propertyInformation?.valuationProvider?.id}"
                                      optionKey="id" optionValue="name" from="${com.next.PropertyValuationProvider.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">资产净值</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="totalPrice" id="totalPrice" value="${propertyInformation?.totalPrice}"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">固定资产名称</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="name" id="name" value="${propertyInformation?.name}"/>
                        </div>
                        <label class="col-md-2 control-label">资产状态</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="status" id="status" value="${propertyInformation?.status}"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">资产类型</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="type" value="${propertyInformation?.type?.id}"
                                      optionKey="id" optionValue="name" from="${com.next.PropertyType.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">入账价值</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="appliedTotalPrice" id="appliedTotalPrice" value="${propertyInformation?.appliedTotalPrice}"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">更新日期</label>

                        <div class="col-md-3 datePicker">
                            <g:datePicker name="modifiedDate"  value="${propertyInformation?.modifiedDate}" precision="day"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <g:hiddenField name="targetUri"  value="${targetUri}"/>
                    <g:hiddenField name="account.id"  value="${this?.propertyInformation?.account?.id}"/>
                    <div class="form-group">
                        <div class="col-md-1 col-md-offset-5">
                            <button class="btn btn-info" type="submit">保存</button>
                        </div>
                    </div>
                </g:form>
            </div>
        </div>
    </div>
</div>
<g:javascript>
    function getCertificateNumber() {
        $.ajax({
            type: "POST",
            url: "/propertyInformation/createCertificateNumber",
            data: {
                serialNumber: $("#certificate").val(),
                account: $("#account").val()
            },

            success: function (data) {

                var id = data.certificate.id;
                $("#certificateId").val(id);
            },
            error: function () {
                swal("获取失败，请稍后重试", "", "error");
            }
        });
    }

</g:javascript>
</body>
</html>
